package org.nvframe.util.settings;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SettingsObj {
	
	private Map<String, SettingItem> settingMap = new HashMap<String, SettingItem> ();

	public void setSetting(String key, String value) {
		settingMap.put(key, new SettingImpl(value));
	}
	
	public void setSetting(String key, List<String> list) {
		settingMap.put(key, new SettingList(list));
	}
	
	public void setSetting(String key, Map<String, String> map) {
		settingMap.put(key, new SettingMap(map));
	}
	
	public boolean containsKey(String key) {
		return settingMap.containsKey(key);
	}

	public int getSize() {
		return settingMap.size();
	}
	
	public SettingList getList(String key) {
		if(!settingMap.containsKey(key) || !(settingMap.get(key) instanceof SettingList))
			return null;
		return (SettingList) settingMap.get(key);
	}
	
	public String getString(String key, String defaultVal) {
		if(!settingMap.containsKey(key))
			return defaultVal;
		return getString(key);
	}
	
	public String getString(String key) {
		return ((Setting) settingMap.get(key)).getString();
	}
	
	public boolean getBoolean(String key, boolean defaultVal) {
		if(!settingMap.containsKey(key))
			return defaultVal;
		return getBoolean(key);
	}
	
	public boolean getBoolean(String key) {
		return ((Setting) settingMap.get(key)).getBoolean();
	}
	
	public int getInt(String key, int defaultVal) {
		if(!settingMap.containsKey(key))
			return defaultVal;
		return getInt(key);
	}
	
	public int getInt(String key) {
		return ((Setting) settingMap.get(key)).getInt();
	}
	
	public float getFloat(String key, float defaultVal) {
		if(!settingMap.containsKey(key))
			return defaultVal;
		return getFloat(key);
	}
	
	public float getFloat(String key) {
		return ((Setting) settingMap.get(key)).getFloat();
	}
	
	public double getDouble(String key, Double defaultVal) {
		if(!settingMap.containsKey(key))
			return defaultVal;
		return getDouble(key);
	}
	
	public double getDouble(String key) {
		return ((Setting) settingMap.get(key)).getDouble();
	}
	
}
